<template>
	<view>
		<image src="../../static/logo-1.png" class="logo" mode="widthFix"></image>
		<view class="logotitle">OA在线办公系统</view>
		<view class="logoversion">版本号：20XX</view>
		<view>
			<button class="login-btn" open-type="getUserInfo" @tap="login()">登陆系统</button>
		</view>
		<view class="register-container">
			没有账号？
			<text class="register" @tap="toRegister()">立即注册</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			toRegister:()=>{
				uni.navigateTo({
					url:'../register/register'
				})
			},
			login:function(){
				let that=this
				uni.login({
					provider:"weixin",
					success:function(resp) {
						let code=resp.code
						console.log('code',code);
						// console.log(that.url.login);
						that.ajax(that.url.login,"POST",{"code":code},function(resp){
							let permission=resp.permission
							console.log(permission);
							uni.setStorageSync("permission",permission)
							uni.showToast({
								title:"登陆成功"
							})
							uni.switchTab({
								url:'../index/index'
							})
						})
					},
					fail:function(e){
						console.log(e);
						uni.showToast({
							icon:"none",
							title:"登陆异常"
						})
					}
				})
			}
		}
	}
</script>

<style lang="less">
	@import url("login.less");
</style>
